//
//  BJNetWorking.m
//  SZBank
//
//  Created by rimi on 16/7/11.
//  Copyright © 2016年 LuoYao. All rights reserved.
//

#import "BJNetWorking.h"
#import "AFNetworking.h"
#define URL_BASE @"http://117.172.47.171:1113/szbank/" //地址

@implementation BJNetWorking

+(BJNetWorking *)shareInstance{
    static BJNetWorking *share = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        share = [[BJNetWorking alloc] init];
    });
    return share;
}

-(void)postRequest:(NSString *)urlString param:(NSDictionary *)parameter success:(MyBlock)success failure:(MyBlock)failure{
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.requestSerializer.timeoutInterval = 10.0f;
    
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", @"text/html", nil];
    
    [manager POST:[NSString stringWithFormat:@"%@%@",URL_BASE,urlString] parameters:parameter progress:^(NSProgress * _Nonnull uploadProgress) {
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        success(responseObject);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        failure(error);
        
        [LocalDataManager addAlertControllerWithControllerTitle:@"提示" controllerMessage:@"网络可能有点问题" actionSureTitle:@"好的" actionCancelTile:nil actionSureBlock:nil actionCancelBlock:nil style:0];
    }];
    
}
@end
